The compose key should now work better with UIM (3/4).
authorDaniel Colascione <dancol@dancol.org>
Sun, 23 Mar 2014 11:35:21 +0000 (04:35 -0700)
committerRob Browning <rlb@defaultvalue.org>
Fri, 15 Aug 2014 22:13:48 +0000 (17:13 -0500)
This upstream patch has been added:

  Further improve create_frame_xic patch

Origin: upstream, commit: r116856.1.3, 5bf310bb4f29b77c91d6805b276d4c66968c599a
Added-by: Rob Browning <rlb@defaultvalue.org>
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753534

src/ChangeLog
src/xfns.c

index 09d645aa3623bffeb4207944442ca0d5c16088d0..e41b5edc168157ccf36ab8c6045ed29e9c7941e4 100644 (file)
@@ -2,7 +2,8 @@
 
        * xfns.c (create_frame_xic): Pass XNStatusAttributes to XCreateIC
        only if xic_style calls for it.  This change allows Emacs to work
-       with ibus.  Also, don't leak resources if create_frame_xic fails.
+       with ibus.  Also, don't leak resources if create_frame_xic fails,
+       and stop caching xic_style across different displays.
 
 2013-08-21  Paul Eggert  <eggert@cs.ucla.edu>
 
index 2fe98c3b8a16da9ddf00eaf789d68fb0360a9f67..76036b8ad0e89b22ede3352ffbcbb224e38afc39 100644 (file)
@@ -2156,8 +2156,6 @@ best_xim_style (XIMStyles *user, XIMStyles *xim)
 
 /* Create XIC for frame F. */
 
-static XIMStyle xic_style;
-
 void
 create_frame_xic (struct frame *f)
 {
@@ -2169,29 +2167,34 @@ create_frame_xic (struct frame *f)
   XRectangle s_area;
   XPoint spot;
   XIMStyles supported_list;
+  XIMStyle xic_style;
 
   if (FRAME_XIC (f))
-    return;
-
-  /* Create X fontset. */
-  xfs = xic_create_xfontset (f);
-  FRAME_XIC_FONTSET (f) = xfs;
+    goto out;
 
   xim = FRAME_X_XIM (f);
-  if (xim)
+  if (!xim)
+    goto out;
+
+  /* Determine XIC style.  */
+  supported_list.count_styles = (sizeof supported_xim_styles
+                                 / sizeof supported_xim_styles[0]);
+  supported_list.supported_styles = supported_xim_styles;
+  xic_style = best_xim_style (&supported_list, FRAME_X_XIM_STYLES (f));
+
+  /* Create X fontset. */
+  if (xic_style & (XIMPreeditPosition | XIMStatusArea))
     {
-      spot.x = 0; spot.y = 1;
+      xfs = xic_create_xfontset (f);
+      if (!xfs)
+        goto out;
 
-      /* Determine XIC style.  */
-      if (xic_style == 0)
-       {
-         supported_list.count_styles = (sizeof supported_xim_styles
-                                        / sizeof supported_xim_styles[0]);
-         supported_list.supported_styles = supported_xim_styles;
-         xic_style = best_xim_style (&supported_list,
-                                     FRAME_X_XIM_STYLES (f));
-       }
+      FRAME_XIC_FONTSET (f) = xfs;
+    }
 
+  if (xic_style & XIMPreeditPosition)
+    {
+      spot.x = 0; spot.y = 1;
       preedit_attr = XVaCreateNestedList (0,
                                          XNFontSet, xfs,
                                          XNForeground,
@@ -2206,50 +2209,62 @@ create_frame_xic (struct frame *f)
 
       if (!preedit_attr)
         goto out;
+    }
 
-      if (xic_style & XIMStatusArea)
-        {
-          s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
-          status_attr = XVaCreateNestedList (0,
-                                             XNArea,
-                                             &s_area,
-                                             XNFontSet,
-                                             xfs,
-                                             XNForeground,
-                                             FRAME_FOREGROUND_PIXEL (f),
-                                             XNBackground,
-                                             FRAME_BACKGROUND_PIXEL (f),
-                                             NULL);
-
-          if (!status_attr)
-            goto out;
-
-          xic = XCreateIC (xim,
-                           XNInputStyle, xic_style,
-                           XNClientWindow, FRAME_X_WINDOW (f),
-                           XNFocusWindow, FRAME_X_WINDOW (f),
-                           XNStatusAttributes, status_attr,
-                           XNPreeditAttributes, preedit_attr,
-                           NULL);
-        }
-      else
-        {
-          xic = XCreateIC (xim,
-                           XNInputStyle, xic_style,
-                           XNClientWindow, FRAME_X_WINDOW (f),
-                           XNFocusWindow, FRAME_X_WINDOW (f),
-                           XNPreeditAttributes, preedit_attr,
-                           NULL);
-        }
-
-      if (!xic)
+  if (xic_style & XIMStatusArea)
+    {
+      s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
+      status_attr = XVaCreateNestedList (0,
+                                         XNArea,
+                                         &s_area,
+                                         XNFontSet,
+                                         xfs,
+                                         XNForeground,
+                                         FRAME_FOREGROUND_PIXEL (f),
+                                         XNBackground,
+                                         FRAME_BACKGROUND_PIXEL (f),
+                                         NULL);
+
+      if (!status_attr)
         goto out;
-
-      FRAME_XIC (f) = xic;
-      FRAME_XIC_STYLE (f) = xic_style;
-      xfs = NULL; /* Don't free below.  */
     }
 
+  if (preedit_attr && status_attr)
+    xic = XCreateIC (xim,
+                     XNInputStyle, xic_style,
+                     XNClientWindow, FRAME_X_WINDOW (f),
+                     XNFocusWindow, FRAME_X_WINDOW (f),
+                     XNStatusAttributes, status_attr,
+                     XNPreeditAttributes, preedit_attr,
+                     NULL);
+  else if (preedit_attr)
+    xic = XCreateIC (xim,
+                     XNInputStyle, xic_style,
+                     XNClientWindow, FRAME_X_WINDOW (f),
+                     XNFocusWindow, FRAME_X_WINDOW (f),
+                     XNPreeditAttributes, preedit_attr,
+                     NULL);
+  else if (status_attr)
+    xic = XCreateIC (xim,
+                     XNInputStyle, xic_style,
+                     XNClientWindow, FRAME_X_WINDOW (f),
+                     XNFocusWindow, FRAME_X_WINDOW (f),
+                     XNStatusAttributes, status_attr,
+                     NULL);
+  else
+    xic = XCreateIC (xim,
+                     XNInputStyle, xic_style,
+                     XNClientWindow, FRAME_X_WINDOW (f),
+                     XNFocusWindow, FRAME_X_WINDOW (f),
+                     NULL);
+
+  if (!xic)
+    goto out;
+
+  FRAME_XIC (f) = xic;
+  FRAME_XIC_STYLE (f) = xic_style;
+  xfs = NULL; /* Don't free below.  */
+
  out:
 
   if (xfs)